//var url = 'http://edu.yzztnet.com/public/api/index.php/jiajiao/interface/';
function geturlcanshu(){

    /* 用途: 接收地直栏参数 取id=1 根据ID的值 */
    var urlinfo=decodeURI(window.location.href); //获取当前页面的url
    var len=urlinfo.length;//获取url的长度
    var offset=urlinfo.indexOf("?");//设置参数字符串开始的位置
    var newsidinfo=urlinfo.substr(offset,len).replace('&','');//取出参数字符串 这里会获得类似“id=1”这样的字符串
    newsidinfo= newsidinfo.replace('?id','');
    newsidinfo= newsidinfo.replace('name','');
    //console.log(newsidinfo);
    var newsids=newsidinfo.split("=");//对获得的参数字符串按照“=”进行分割
    return newsids;
}
//格式化时间戳函数
function formatDateTime(timeStamp) {
    var date = new Date();
    date.setTime(timeStamp * 1000);
    var y = date.getFullYear();
    var m = date.getMonth() + 1;
    m = m < 10 ? ('0' + m) : m;
    var d = date.getDate();
    d = d < 10 ? ('0' + d) : d;
    var h = date.getHours();
    h = h < 10 ? ('0' + h) : h;
    var minute = date.getMinutes();
    var second = date.getSeconds();
    minute = minute < 10 ? ('0' + minute) : minute;
    second = second < 10 ? ('0' + second) : second;
    return y + '-' + m + '-' + d+' '+h+':'+minute+':'+second;
};

var newsids=geturlcanshu();
var id= newsids[1];
sessionStorage.setItem('id',id);
var name =newsids[2];

$.ajax({
    url:url+'gettechdetails?id='+id,
    type:'post',
    data:{},
    dataType:'json',
    async:'true',
    timeout:2000,
    success:function (data) {
        if(data.code==1000&&data.status==1){
            var teDetails = data.data;
          $('title').text(teDetails['teachers']['xingming']+'详细页面');
          title = teDetails['teachers']['xingming'];
            imgurl = teDetails['teachers']['headimage'];
          
            desc = teDetails['teachers']['jianjie'];
            $('.index_carousel>.swiper-wrapper').html('<div class="swiper-slide"><img src="'+teDetails['teachers']['headimage']+'" class="auto_img"></div>');
            $('#renzhengxx').html('<p><span><b>姓名:</b>'+teDetails['teachers']['xingming']+'</span></p>'+'<p><span><b>毕业院校:</b>'+teDetails['teachers']['yuanxiao']+'</span></p>'+'<p><span><b>工作单位:</b>'+teDetails['teachers']['danwei']+'</span></p>  '+'<p><span><b>剧种:</b>'+teDetails['teachers']['juzhong']+'</span></p>  '+'<p><span><b>行当:</b>'+teDetails['teachers']['hangdang']+'</span></p>  ');

            $('#rongyu').html('<p><span><b>简介:</b>'+teDetails['teachers']['jianjie']+'</span></p>'+'<p><span><b>荣誉:</b>'+teDetails['teachers']['rongyu']+'</span></p>'+'<p><span><b>影视作品:</b>'+teDetails['teachers']['jumu']+'</span></p>');
            var html='';
            if(teDetails['pinglun'].length!=0){
                $.each(teDetails['pinglun'],function (k,v) {
                    var time = this.dottime;
                    this.dottime = formatDateTime(time);
                    html +='<div class="header_h teacher_honor">'
                        +'<p><span><b>'+this.pinglunname+':</b></span>'+this.content+'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>评论时间:</b>'+this.dottime+'</p>'
                        +'</div>';
                })
                $('#pinglun').html(html);
            }else {
                $('#pinglun').html('<div class="header_h teacher_honor">'
                    +'<p>暂无评论</p>'
                    +'</div>');
            }
        }
    },
    error:function () {
        console.log('数据加载失败');
    }

});